﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using SEOBlog.Services;

namespace SEOBlog.Web
{
    public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            var pagesService = new PagesService();
            var pages = pagesService.GetAllPages();

            foreach (var page in pages)
            {
                routes.MapRoute(page.FriendlyUrl, page.FriendlyUrl, new {controller = "Front", action = "Index"});
            }

            routes.MapRoute("AdminRoute", "admin", new {controller = "Admin", action = "Index"});

            /*routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Front", action = "Index", id = UrlParameter.Optional }
            );*/
        }
    }
}